clear all
global system "linux"

if "${system}" == "linux" {
	global code "/"
	global s "/"
}

run "${code}${s}_set-path.do"
cd "${code}/tba_elig"

use  "${hpc}/ob-cll-cleaned.dta" if year <= 2013 & abs(PaboveC) <= 150, clear

keep if gse_id == 1

foreach x in purchaseprice loanamount {
	replace `x' = `x'/1000
}

eststo clear
eststo: qui estpost su HiP HiBal purchaseprice loanamount rate fico , d

label var gse_id "Share of loans sold to the GSEs"
label var HiP "Share of loans with appraisal value > 1.25xCLL"
label var HiBal "Share of high-balance loans"
label var purchaseprice "Appraisal Value (\textdollar 1,000)"
label var loanamount "Loan Size (\textdollar 1,000)"
label var rate "Mortgage rate (\%)"
label var fico "Credit score"


global keepvar "keep(purchaseprice loanamount rate fico)"

esttab using "${table}/ob-sumstat.tex", label replace nomtitle nonumber /// 
  stats(N, fmt(%9.0fc) label("N. Obs."))  ///
 cell("mean(fmt(%11.2fc)) min($keepvar) p25($keepvar) p50($keepvar) p75($keepvar) max($keepvar)") collabels("Mean" "Min" "p25" "Median" "p75" "Max")
